import smtplib

from email.mime.text import MIMEText
from email.header import Header

# 第三方SMTP服务
mail_host='smtp.163.com'
mail_user ='lixianshengchao@163.com'
mail_pass = 'QTXWOTEUSHARYDWT'

sender = 'lixianshengchao@163.com'
receivers =['798121446@qq.com'] #接收邮件

message = MIMEText('今晚哪里吃饭','plain','utf-8')
message['From'] = "lixianshengchao@163.com"
message['To'] = "798121446@qq.com"

subject = '今晚哪里吃饭'
message['Subject'] = Header(subject,'utf-8')

try:
    smtpObj = smtplib.SMTP()
    smtpObj.connect(mail_host,25) #25为SMTP端口号
    smtpObj.login(mail_user,mail_pass)
    smtpObj.sendmail(sender,receivers,message.as_string())
    print('邮件发送成功')
except smtplib.SMTPException:
    print('Error:无法发送邮件')
    raise